/*
 * TipoTarifaDAO.java
 *
 * Created on 30 de abril de 2007, 03:49 PM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package com.src.computec.radar.services.utilities.dao;

import com.src.computec.radar.base.dao.GenericDAO;
import com.src.computec.radar.base.dao.exception.DAOException;
import com.src.computec.radar.services.base.constantes.ConstantesGenerales;
import com.src.computec.radar.services.utilities.dto.TipoTarifaDto;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author jlperea
 */
public class TipoTarifaDAO extends GenericDAO implements BaseTipoTarifaDAO 
{
    private ConstantesGenerales constantesGenerales;
    private String SCHEMA;
    
    /** Creates a new instance of TipoTarifaDAO */
    public TipoTarifaDAO() 
    {
        constantesGenerales = ConstantesGenerales.getInstance();
        SCHEMA = constantesGenerales.SCHEMA;
    }
    
    public List getTiposTarifa() throws DAOException 
    {
        List retornoLst = new ArrayList();
        Connection con = null;
        PreparedStatement statement = null;
        ResultSet rs = null;
        
        try {
            con = getConnectionDB2();
            statement = con.prepareStatement("SELECT CODIGO_TIPO_TARIFA, DESCRIPCION FROM " + SCHEMA + ".TIPO_TARIFA ORDER BY DESCRIPCION ASC ");            
            rs = statement.executeQuery();
            
            while (rs.next()) 
            {
                int indice1 = 0;
                TipoTarifaDto dto = new TipoTarifaDto();
                dto.setCodigoTipoTarifa(rs.getString(++indice1));
                dto.setDescripcion(rs.getString(++indice1));
                retornoLst.add(dto);
            }
        } 
        catch (SQLException e) 
        {
            throw new DAOException("InsertoDAO:getTiposTarifa: " + e.toString(), e);
        }
        finally 
        {
            closeConnection(con, statement, rs);
        }
        return retornoLst;
    }
}
